//
//  UIView+Extension.swift
//  Weibo
//
//  Created by 贵永冬 on 16/7/16.
//  Copyright © 2016年 贵永冬. All rights reserved.
//

import UIKit

extension UIView {
    public var left : CGFloat {
        get{
            return self.frame.origin.x
        }
        set{
            var newframe = self.frame
            newframe.origin.x = newValue
            self.frame = newframe
        }
    }
    public var top : CGFloat {
        get{
            return self.frame.origin.y
        }
        set{
            var newframe = self.frame
            newframe.origin.y = newValue
            self.frame = newframe
        }
    }
    public var right : CGFloat {
        get{
            return self.frame.origin.x + self.frame.size.width
        }
        set{
            var newframe = self.frame
            newframe.origin.x = newValue - newframe.size.width
            self.frame = newframe
        }
    }
    public var bottom : CGFloat {
        get{
            return self.frame.origin.y + self.frame.size.height
        }
        set{
            var newframe = self.frame
            newframe.origin.y = newValue - newframe.size.height
            self.frame = newframe
        }
    }
    public var width : CGFloat {
        get{
            return self.frame.size.width
        }
        set{
            var newframe = self.frame
            newframe.size.width = newValue
            self.frame = newframe
        }
    }
    public var height : CGFloat {
        get{
            return self.frame.size.height
        }
        set{
            var newframe = self.frame
            newframe.size.height = newValue
            self.frame = newframe
        }
    }
    public var centerX : CGFloat {
        get{
            return self.center.x
        }
        set{
            self.center = CGPoint(x: newValue, y: self.center.y)
        }
    }
    public var centerY : CGFloat {
        get{
            return self.center.y
        }
        set{
            self.center = CGPoint(x: self.center.y, y: newValue)
        }
    }
    public var origin : CGPoint {
        get{
            return self.frame.origin
        }
        set{
            var newframe = self.frame
            newframe.origin = newValue
            self.frame = newframe
        }
    }
    public var size : CGSize {
        get{
            return self.frame.size
        }
        set{
            var newframe = self.frame
            newframe.size = newValue
            self.frame = newframe
        }
    }
    
}

